let baseUrl = "https://www.peklm.com/api/"
// let baseUrl = "http://localhost:14573/"


export function request(url, method, data) {
    return new Promise((resolve, reject) => {
        if(url.substring(0,1) == '/')
            url = url.substring(1)
        uni.request({
            url: baseUrl + url,
            method: method,
            data: data,
            timeout: 10000,
            success: (res) => {
                resolve(res.data)
            },
            fail: (error) => {
                console.log(error)
                uni.showToast({
                    icon: 'none',
                    title: '请求失败'
                })
            }
        })
    })
}

export function get(url, data) {
    return request(url, 'get', data)
}

export function post(url, data) {
    return request(url, 'post', data)
}